<?php

use App\Models\ChargeRecord;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;

class CreateChargeRecordsTable extends Migration{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up(){
        //充值记录表
        Schema::create('charge_records', function (Blueprint $table) {
            $table->increments('id');
            //订单号
            $table->string('order_number');
            //用户 id
            $table->integer('user_id')->nullable();
            //管理员id
            $table->integer('admin_id')->nullable();
            //撤销管理员id
            $table->integer('discharge_admin_id')->nullable();
            $table->integer('discharge_flow')->nullable();
            $table->integer('device_id');
            //openid
            $table->string('open_id')->nullable();
            //金额
            $table->double('money')->nullable();
            //流量数
            $table->integer('flow');
            $table->integer('residual_flow');
            $table->text('remark')->nullable();
            //支付状态
            $table->tinyInteger('status')->default(ChargeRecord::ORDER_STATUS_WAIT_PAYMENT);
            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down(){
        Schema::drop('charge_records');
    }
}
